/*
 * protocol.h
 *
 * 	Ex: 5
 *
 *  Created on: Jun 6, 2012
 *      Author: Ariel Ayash
 */

#ifndef PROTOCOL_H_
#define PROTOCOL_H_

#include <stdint.h>

// the size of the header of the message
#define MSG_METADATA_LENGTH (sizeof(messages_header_t))

typedef enum
{
	MESSAGE_TYPE_MIN_NUM					= 0	,
	MESSAGE_TYPE_CONNECT						,
	MESSAGE_TYPE_CONNECT_RESPONSE				,
	MESSAGE_TYPE_DISCONNECT						,
	MESSAGE_TYPE_FOLLOW							,
	MESSAGE_TYPE_FOLLOW_RESPONSE				,
	MESSAGE_TYPE_UNFOLLOW						,
	MESSAGE_TYPE_UNFOLLOW_RESPONSE				,
	MESSAGE_TYPE_TWIT							,
	MESSAGE_TYPE_TWIT_RESPONSE					,
	MESSAGE_TYPE_DIRECT_MESSAGE					,
	MESSAGE_TYPE_DIRECT_MESSAGE_RESPONSE		,
	MESSAGE_TYPE_PUBLIC_ANNOUNCEMENT			,
	MESSAGE_TYPE_PUBLIC_ANNOUNCEMENT_RESPONSE	,
	MESSAGE_TYPE_WHO							,
	MESSAGE_TYPE_WHO_RESPONSE					,
	MESSAGE_TYPE_MAX_NUM

} messages_type_t;


typedef enum
{
	RESPONSE_STATUS_SUCCESS				= 0,
	RESPONSE_STATUS_ERROR				= 1,

} response_status_t;

// meta data of the message
typedef struct
{
	messages_type_t type;
	uint32_t payload_length;
	response_status_t status;

} messages_header_t;

typedef struct
{
	messages_header_t header;
	char payload[1];					// must be the last field

} out_msg_t;

typedef struct
{
	messages_header_t header;
	char *payload;						// must be the last field

} in_msg_t;


#endif /* PROTOCOL_H_ */
